#include "RollPath.h"
#include "vmath.h"
#include <functional>
#include <vector>

using std::vector;


RollPath::RollPath(float pathLength, float radius, float step/* = 0.1f*/) 
	:pathLength(pathLength),
	radius(radius),
	step(step)
{
	this->createRollPath();
}

RollPath::~RollPath()
{
}

float RollPath::interpolation(int index, float angle)
{
	return 0.001f * index;
}

void RollPath::createRollPath()
{
	size_t count = static_cast<size_t>(pathLength / step);
	this->path.clear();
	this->path.reserve(count * 2);
	float angle(0), currentR(radius);
	float x(0), y(0);
	for (size_t i = 0; i <= count; i++)
	{
		angle = (i * step) / radius;
		currentR = radius - this->interpolation(i, angle);
		x = currentR * sin(angle);
		y = currentR * cos(angle) * -1 + radius;
		this->path.push_back(x);
		this->path.push_back(y);
	}
}

